package com.zougen202301180355.restaurant.service.impl;

import com.zougen202301180355.restaurant.mapper.OrderDetailsMapper;
import com.zougen202301180355.restaurant.pojo.OrderDetail;
import com.zougen202301180355.restaurant.service.OrderDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author 邹根
 * 订单详情服务实现类
 */
@Service
@Transactional
public class OrderDetailsServiceImpl implements OrderDetailsService {

    @Autowired
    private OrderDetailsMapper orderDetailsMapper;

    @Override
    public void addOrderDetail(OrderDetail orderDetail) {
        orderDetailsMapper.insert(orderDetail);
    }

    @Override
    public void deleteOrderDetail(Integer id) {
        orderDetailsMapper.delete(id);
    }

    @Override
    public void updateOrderDetail(OrderDetail orderDetail) {
        orderDetailsMapper.update(orderDetail);
    }

    @Override
    public OrderDetail getOrderDetailById(Integer id) {
        return orderDetailsMapper.selectById(id);
    }

    @Override
    public List<OrderDetail> getAllOrderDetails() {
        return orderDetailsMapper.selectAll();
    }

    @Override
    public List<OrderDetail> getOrderDetailsByOrderId(Integer orderId) {
        return orderDetailsMapper.selectByOrderId(orderId);
    }

    @Override
    public List<OrderDetail> getOrderDetailsWithMenuItem(Integer orderId) {
        return orderDetailsMapper.selectWithMenuItem(orderId);
    }
}
